package com.jiazhong.mingxing.project.bookstore.front.listener;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jiazhong.mingxing.project.bookstore.commons.bean.Order;
import com.jiazhong.mingxing.project.bookstore.commons.mapper.OrderMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "ab124", topic = "order", selectorExpression = "success", messageModel = MessageModel.BROADCASTING)
public class UpdateOrderStateListener implements RocketMQListener<String> {
    @Mapper
    private OrderMapper orderMapper;

    @Override
    public void onMessage(String s) {
        UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", s);
        updateWrapper.set("status", 1);
        orderMapper.update(updateWrapper);
    }
}
